package com.wangjiacai.hqlQuery.role.converter;



import com.wangjiacai.hqlQuery.role.entity.Function;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-26 14:00:35
 */
public class FunctionConverter {

    public static Map converterToMap(Function function){
        Map<String,Object> map=new HashMap<>();
        map.put("id",function.getBh());
        map.put("text",function.getName());
        map.put("icon",function.getIcon());
        if(function.getBh().length()==6){
            map.put("parent","#");
        }else{
            map.put("parent",function.getBh().substring(0,6));
        }
        return map;
    }

    public static List<Map> converterToMapList(List<Function> functions){
        List<Map> list=new ArrayList<>();
        for(Function function:functions){
            list.add(converterToMap(function));
        }
        return list;
    }

}
